package tech.aistar.day12;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/3/23 10:26 上午
 */
public class TestGender {
    public static void main(String[] args) {
        //枚举类型不能new
        Gender f = Gender.F;
        Gender f1 = Gender.F;

        Gender m= Gender.M;
        System.out.println(f == f1);//true
        System.out.println(f==m);//false

        Student s1 = new Student(1L,"admin",Gender.F);

        System.out.println(s1);

        //页面表单 - 性别男,女 - 提交按钮 - 后台
        //后台接受到的数据都是String类型.
        String sex = "M";

        System.out.println(Gender.class);

        //将字符串类型->枚举类型
        //前提 - 字符串的值要和枚举常量的名称保持一致
        Gender g = Enum.valueOf(Gender.class,sex);
        Student s2 = new Student(2L,"tom",g);
        System.out.println(s2);

        //枚举类型转成字符串类型
        System.out.println(f.toString());

//        g = null;//
//        System.gc();


    }
}
